<?php
/**
 * 发包权限
 */
namespace Api;
use Kuyuan\WqCore\api\Api;
use Kuyuan\WqCore\util\Util;

class RedAccess extends Api
{
    private $RedAccess = null;
    public function __construct()
    {
        parent::__construct();
        $this->RedAccess = new \Controller\RedAccess();
    }

    /**
     * 获取申请发红包权限二维码
     */
    public function getAddQrcode()
    {
        Util::appointGet();
        $_qrcode = $this->RedAccess->getAddQrcode();
        $_result = array("code"=>0,"data"=>$_qrcode);
        Util::returns($_result);
    }

    /**
     * 获取可发红包用户列表
     */
    public function getList()
    {
        Util::appointGet();
        $_list = $this->RedAccess->getList();
        if($_list && count($_list)) {
            $_result = array("code"=>0,"data"=>$_list);
        } else {
            $_result = array("code"=>101);
        }
        Util::returns($_result);
    }

    /**
     * 修改状态
     */
    public function changeStatus()
    {
        Util::appointPost();
        if($this->RedAccess->edit(
            array("status"=>$this->_gpc["status"]),
            $this->_gpc["uid"]
        )) {
            $_result = array("code"=>0);
        } else {
            $_result = array("code"=>103);
        }
        return Util::returns($_result);
    }
}